package com.chan.controller;

import com.chan.model.Demo;
import com.chan.service.DemoService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2016/9/23.
 */
@RestController
@RequestMapping("/cache")
public class DemoController {

    @Resource
    private DemoService demoService;

    @RequestMapping("/test")
    public String test(){
        demoService.test();
        System.out.println("-------demoService.test()-------");
        return "ok";
    }


    @RequestMapping("/delete/{id}")
    public String testDeleteFromCache(@PathVariable Long id){
        demoService.deleteFromCache(id);
        return "ok";
    }

    @RequestMapping("/get/{id}")
    public String testCache(@PathVariable Long id){
        Demo demo = demoService.findById(id);
        return demo.toString();
    }

    @RequestMapping("/delall")
    public String deleteAll(){
        demoService.deleteAllCache();
        return "ok";
    }
}
